#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

const int inf = 1e9;

int main() {
    vector<vector<int>> matrix;
    vector<vector<int>> dynamics;
    int n, m;
    cin >> n >> m;
    matrix.resize(n + 1);
    dynamics.resize(n + 1);
    for (int i = 0; i < n + 1; ++i) {
        matrix[i].resize(m + 1, 0);
        dynamics[i].resize(m + 1, 0);
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> matrix[i][j];
        }
    }
    dynamics[0][1] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (matrix[i][j])
                dynamics[i][j] = (dynamics[i - 1][j] + dynamics[i][j - 1]) % 268435459;
        }
    }

    cout << dynamics[n][m] << endl;
}
